package com.liuxl.wqdc.repository;

import com.liuxl.wqdc.entity.Record;
import com.liuxl.wqdc.entity.TwoLevelQuestion;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RecordRepository extends JpaRepository<Record, Integer>, JpaSpecificationExecutor<Record> {

    List<Record> findByTwoLevelQuestionIdInAndIsDelete(List<Integer> list, String isDelete);

    @Query(value = "select record from Record record where record.twoLevelQuestionId in ?1 and record.isDelete = '0'")
    Page<Record> findRecordByTwoQuestionIdAndPage(List<Integer> twoLevelQuestionIdList, Pageable pageable);

    @Modifying
    @Query(value = "insert into record(two_level_question_id,result1,result2,result3,student_name) values(?1,?2,?3,?4,?5)", nativeQuery = true)
    int addRecord(Integer twoLevelQuestionId, String result1, String result2, String result3, String student_name);

    List<Record> findByWenquanId(String wenquanId);

    Page<Record> findByFinishYearsAndTwoLevelQuestionIdInAndIsDelete(String finishYears, List<Integer> twoLevelQuestionIdList, String isDelete,Pageable pageable);
}


